﻿using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
    public class SkuInfoMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public SkuInfoMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {
            _cfg.CreateMap<SkuValue, sku_value_dto>()
                .ForMember(dest => dest.sku_id, src => src.MapFrom(c => c.SkuId));
            _cfg.CreateMap<sku_info_model, SkuInfo>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Name, src => src.MapFrom(c => c.name));
            _cfg.CreateMap<SkuInfo, sku_info_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.name, src => src.MapFrom(c => c.Name))
                .ForMember(dest => dest.sku_values, src => src.MapFrom(c => c.SkuValues));
        }
    }
}
